import axios from 'axios'

const http = axios.create({
    // 设置超时时间
    timeout: 30000,


    // baseURL: process.env.NODE_ENV === "development" ? '/api2' : `${window.location.origin}/`,
    baseURL:'http://192.168.8.6:9090/',
})
// 添加请求拦截器
http.interceptors.request.use(
    config => {
        window.localStorage.setItem('jwt_time', new Date().getTime().toString())
        config.headers['Authorization'] = `Bearer ${window.localStorage.getItem('thingsBoard_jwt_token')}`
        return config
    },
    error => {
        return Promise.reject(error)
    }
)


http.interceptors.response.use(
    response => {
        const res = response.data
        console.log(11111)
        return res
    },
    error => {
        console.log(2222)
        return Promise.reject(error)
    }
)

export default http
